<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
            <title>
                测试
            </title>
        </meta>
    </head>
    <body>
        <button id="add">设置</button>
        <button id="get">获取</button>
        <button id="rem">清除</button>
        
    <script type="text/javascript">
        function getQueryVariable(variable) {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) {return pair[1];}
            }
            return (false);
        }

        document.getElementById("add").onclick = function() {
            window.localStorage.setItem('aaaa','bbbb');
        }

        document.getElementById("get").onclick = function() {
            var a = window.localStorage.getItem('aaaa');
            alert(a);
        }

        document.getElementById("rem").onclick = function() {
            var a = window.localStorage.removeItem('aaaa');
        }

        var p = getQueryVariable("p");
        if (p == 1) {
            window.localStorage.setItem('aaaa','remove');
        }
    </script>
    </body>
</html>
